package com.ben.chatroom.common.zk;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * @author huangyijun
 */
public class ClientFactory {

  /**
   * 创建单例
   */
  public static CuratorFramework createSimple(String connectionString, String timeout) {
    //重试机制：第一次重试等待1s，第二次重试等待2s，第三次重试等待4s
    ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3);

    return CuratorFrameworkFactory.newClient(connectionString, Integer.parseInt(timeout),
      Integer.parseInt(timeout), retryPolicy);
  }



}
